package com.cysion.study.presenter

import com.cysion.study.ktbox.base.BasePresenter
import com.cysion.study.ktbox.net.BaseResponseRx
import com.cysion.study.ktbox.net.ErrorHandler
import com.cysion.other.addTo
import com.cysion.targetfun._subscribe
import com.cysion.study.helper.UserCache
import com.cysion.study.ktbox.Box
import com.cysion.study.ktbox.utils.ACache
import com.cysion.study.net.ApiClient
import com.cysion.study.ui.iview.NoticeView

class NoticePresenter : BasePresenter<NoticeView>() {
    fun getDataList(curPage: Int) {
        checkViewAttached()
        //1教师  2家教
        var cert = ACache.get(Box.context).getAsString("teacherType")
        ApiClient.api.getNoticeList(UserCache.token,curPage,cert,"","")
            .compose(BaseResponseRx.validateToMain())
            ._subscribe {
                _onNext {
                    attchedView?.stopLoad()
                    attchedView?.onProMoney(it)
                }
                _onError {
                    attchedView?.stopLoad()
                    attchedView?.onGetProMoneyError(ErrorHandler.handle(it))
                }
            }.addTo(compositeDisposable)
    }
}